home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
js
/
photo1Layout4-src.js
< prev
next >
Wrap
Text File
|
2010-05-19
|
6KB
|
158 lines
var dOpt=INERTIA+CURSOR_HAND+SCALABLE+ROT;
var tnImgW={}; // Max loaded width
var tnImgSel={}; // Currently selected image
// Hide image loading to avoid flickers
var cacheId,cacheImg=new Image(); cacheImg.onload=function(){if(dgi(cacheId)) dgi(cacheId).src=cacheImg.src}
// Adjust frames
function winResized(){
alignBottom(dgi("noFileDiv"),winMe,15);
alignBottom(dgi("thumbnailsFrame"),winMe,10);
if(dgi('actionsPanel').style.display!='none' && treeDivId) alignBottom(dgi(treeDivId),dgi("thumbnailsFrame"),0);
}
/**
* Generate thumbnails layout
* files: array of files (Cf. )
* tnw: thumbnails max width
* tnh: thumbnails max height
*/
function filesLayoutResource(files,tnw,tnh){
var f,u,i,o,r,x,y,p=Math.ceil(tnw/10),names='',mw,mh;
dgi('noFileDiv').style.paddingBottom=(tnh)+'px';
dgi('noFileDiv').style.paddingRight=(tnw)+'px';
alignBottom(dgi('noFileDiv'),winMe);
tnImgW={};tnImgSel={}
fL.noLeftClickCM=fL.noTooltip=1;
fL.previewOnCM=layout4Preview;
//fL.contextMenuExtra=layout4ContextMenu;
r=dgi('noFileDiv').offsetWidth/dgi('noFileDiv').offsetHeight;
mh=100*Math.sqrt(tnw*tnh*files.length/0.7*r);mw=mh*r;
mw=Math.max(0,Math.min(100,mw/dgi('noFileDiv').offsetWidth));
mh=Math.max(0,Math.min(100,mh/dgi('noFileDiv').offsetHeight));
o='<div id="filesTable" style="margin-right:'+tnw+'px;height:100%;width:100%;position:relative">';
for(i=0;i<files.length;i++) {
f=files[i];
r=20*Math.random()-10;
x=50+mw*Math.random()-mw/2;
y=50+mh*Math.random()-mh/2;
u='<div id="_id'+i+'" style="position:absolute;width:'+(f[16])+'px;height:'+(f[17])+'px;left:'+x+'%;top:'+y+'%;-webkit-transform:rotate('+r+'deg);-o-transform:rotate('+r+'deg);-moz-transform:rotate('+r+'deg)" class="photoFrame" onmousedown="fL.sDF(this,dOpt)" ondblclick="view(\'id'+i+'\')" onmouseup="fL.cm(this,event)" onmouseover="tooltip(this,layout4TC)">';
u+='<img id="img'+i+'" style="width:'+((phpBrowser=='ie')?100:90)+'%;height:86%;margin:5%" onload="layout4Loaded(this)" aalt="'+f[15]+'" onmousedown="fL.sDF(this.parentNode,dOpt)">';
u+='</div>';
o+=u;
names+='<div id="id'+i+'" style="display:none">'+f[2]+'</div>';
}
zI=i;
return o+names+'</div>';
}
// Function called on image resize completed: update src if larger image
function resizeComplete(){
var i,n,obj;
obj=dd.obj;
n=obj.div.getElementsByTagName('IMG')[0];
i=n.id.substr(3)
if(tnImgW[i]>obj.w) return;
tnImgW[i]=obj.w;
n.src=wl.extImageSrc(fL.dir+'/'+fL.files[i][2],obj.w,obj.h);
}
// TN img load queue processing
var layout4State;
function layout4Load(i){
layout4State[i]=1;
var n=dgi('img'+i);
if(!n) return;
if(n.tagName!='IMG') n=n.firstChild;
n.src=n.getAttribute('aalt');
}
function layout4Loaded(n){
var l=fL.files.length;
n=n.parentNode;
n.style.visibility='visible';
for(i=0;i<l;i++) if(!layout4State[i]) {
layout4State[i]=1;
if(phpBrowser=='ie') setTimeout('layout4Load('+i+')',1); else layout4Load(i);
return;
}
}
// Set tooltip content (Ctrl hint)
function layout4TC(){return '<img src='+resizeHintImg+'>'}
function layout4STB(id){dd.elements['_'+id].minimizeZ()}
// Before tn gen
function filesListBeforeDraw(files,tnw,tnh){}
// After tn gen
function filesListAfterDraw(files,tnw,tnh){
//alert(dd.obj.id.subtr(3))
layout4State={}
for(var i=0;i<Math.min(10,fL.files.length);i++) layout4Load(i);
}
function preDrop(){
if(dd.obj.x+dd.obj.w/2<actualOffsetLeft(dgi('noFileDiv')) || dd.obj.y+dd.obj.h/2<actualOffsetTop(dgi('noFileDiv'))) dd.obj.elasticTmp=1;
// If selected image is moved, don't reduce it at next image select
if(tnImgSel && tnImgSel.nid==dd.obj.id.substr(3) && dgi('ctrlGroup')) tnImgSel.moved=1;
}
// onclick
function layout4Preview(id){
var obj,f,nid=id.substr(2),s=previewSize,pnid=tnImgSel.nid;
// Remove controls and move previous image back to position
if(pnid) {
f=fL.files[pnid];
obj=dd.elements['_id'+pnid];
layout4InsertControls(obj.div,0);
if(pnid==nid || !tnImgSel.moved){
obj.noLaunch=1;
if(tnImgSel['x']!=undefined) layout4PreviewAnim(tnImgSel.nid,tnImgSel.x,tnImgSel.y,f[16],f[17],(obj.angle!=0)?obj.angle:tnImgSel.angle,7,0);
else layout4PreviewAnim(tnImgSel.nid,obj.x+(s-f[16])/2,obj.y+((s-f[16])/2)*f[17]/f[16],f[16],f[17],(obj.angle!=0)?obj.angle:tnImgSel.angle,7,0);
}
}
if(tnImgSel.nid===nid){
tnImgSel={}
}
else{
obj=dd.elements['_id'+nid];
tnImgSel={'nid':nid,'angle':obj.angle,'x':obj.x,'y':obj.y}
f=fL.files[nid];
cacheId='img'+nid;
cacheImg.src=wl.extImageSrc(fL.dir+'/'+f[2],s,s*f[17]/f[16]);
obj.noLaunch=1; // Prevent object to be launched before/during anim
layout4PreviewAnim(nid,actualOffsetLeft(dgi('noFileDiv'))+dgi('noFileDiv').offsetWidth/2-s/2,actualOffsetTop(dgi('noFileDiv'))+dgi('noFileDiv').offsetHeight/2-s*f[17]/f[16]/2,s,s*f[17]/f[16],0,7,1)
}
}
function layout4PreviewAnim(nid,dx,dy,dw,dh,da,step,sc){
var obj=dd.elements['_id'+nid]
if(--step==0){
obj.moveTo(dx,dy);
obj.resizeTo(dw,dh);
obj.rotTo(da);
if(sc) layout4InsertControls(obj.div,1);
obj.noLaunch=0;
return;
}
var mult=0.5, x=(obj.x+dx)*mult,y=(obj.y+dy)*mult,w=(obj.w+dw)*mult,h=(obj.h+dh)*mult,a=(obj.angle+da)*mult;
obj.moveTo(x,y);
obj.resizeTo(w,h);
obj.rotTo(a);
setTimeout("layout4PreviewAnim("+nid+","+dx+","+dy+","+dw+","+dh+","+da+","+step+","+sc+")",10);
}
function layout4InsertControls (n,ins){
if(!ins) return removeNode(n.lastChild);
var d=D.createElement('DIV'); d.id='ctrlGroup';
with(d.style){position='absolute';top=2;left=2;}
d.innerHTML=dgi('ctrlCont').innerHTML;
n.appendChild(d)
}
winResized();